package it.das.proxy;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class TaskCProxy implements MethodInterceptor{

	@Override
	public Object invoke(MethodInvocation methodInvocation) throws Throwable {
		// same with MethodBeforeAdvice
		System.out.println("PROXY of TaskC - START");
		System.out.println("HijackAroundMethod : Before method! (" + methodInvocation.getMethod().getName() + ")");
		try {
			// proceed to original method call
			Object result = methodInvocation.proceed();
			// same with AfterReturningAdvice
			System.out.println("HijackAroundMethod : After method!" + methodInvocation.getMethod());
			System.out.println("PROXY of TaskC - END");
			return result;
 
		} catch (IllegalArgumentException e) {
			// same with ThrowsAdvice
			System.out.println("HijackAroundMethod : Throw exception!");
			throw e;
		}
	}
}
